package com.hfy.music.controller;

import com.hfy.model.dto.RecentDto;
import com.hfy.music.service.RecentMusicService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.Parameters;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import result.Result;

/**
 * @ author 韩
 * time: 2024/5/30 19:39
 */

@RestController
@RequestMapping("/recent")
@Tag(name = "最近播放业务处理器",description = "在播放音乐的时候就直接添加最近播放")
public class RecentMusicController {

    @Autowired
    private RecentMusicService recentMusicService;

    @Operation(summary = "在播放音乐时 添加一条最近播放记录")
    @Parameters({
            @Parameter(name = "account",description = "账号"),
            @Parameter(name = "musicId",description = "音乐id")
    })
    @PostMapping("/add")
    public Result addRecent(@RequestBody RecentDto dto) {

        return recentMusicService.addRecent(dto);
    }


    @Operation(summary = "查询最近播放记录（500条）")
    @Parameters({
            @Parameter(name = "account",description = "账号")
    })
    @GetMapping("/query")
    public Result queryRecent(@RequestParam Long account) {

        return recentMusicService.queryRecent(account);
    }


    @Operation(summary = "查询最近播放记录条数")
    @Parameters({
            @Parameter(name = "account",description = "账号")
    })
    @GetMapping("/num")
    public Result queryRecentNum(@RequestParam Long account) {

        return recentMusicService.queryRecentNum(account);
    }

}
